VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Begin VB.Form frmSMS 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "vbsms+"
   ClientHeight    =   3165
   ClientLeft      =   150
   ClientTop       =   720
   ClientWidth     =   4815
   ClipControls    =   0   'False
   Icon            =   "frmSMS.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   OLEDropMode     =   1  'Manual
   ScaleHeight     =   211
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   321
   StartUpPosition =   3  'Windows Default
   Begin VB.Timer Timer1 
      Interval        =   1
      Left            =   4170
      Top             =   2280
   End
   Begin VB.PictureBox picScreen 
      BackColor       =   &H00000000&
      BorderStyle     =   0  'None
      Height          =   1455
      Left            =   270
      ScaleHeight     =   97
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   109
      TabIndex        =   0
      Top             =   150
      Width           =   1635
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   3390
      Top             =   420
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Menu mnuMainMenus 
      Caption         =   "&file"
      Index           =   0
      Begin VB.Menu mnuLoadROM 
         Caption         =   "&load rom..."
      End
      Begin VB.Menu mnuCloseROM 
         Caption         =   "&close rom"
      End
      Begin VB.Menu mnuBreak0 
         Caption         =   "-"
      End
      Begin VB.Menu mnuState 
         Caption         =   "&save state"
         Begin VB.Menu mnuStateSave 
            Caption         =   "&save"
         End
         Begin VB.Menu mnuStateLoad 
            Caption         =   "&load"
         End
         Begin VB.Menu mnuBreak7 
            Caption         =   "-"
         End
         Begin VB.Menu mnuStateSlotNumber 
            Caption         =   "&slot number"
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&0"
               Index           =   0
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&1"
               Index           =   1
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&2"
               Index           =   2
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&3"
               Index           =   3
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&4"
               Index           =   4
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&5"
               Index           =   5
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&6"
               Index           =   6
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&7"
               Index           =   7
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&8"
               Index           =   8
            End
            Begin VB.Menu mnuStateSlot 
               Caption         =   "&9"
               Index           =   9
            End
         End
      End
      Begin VB.Menu mnuMovie 
         Caption         =   "&movie state"
         Begin VB.Menu mnuMovieRecord 
            Caption         =   "&record"
         End
         Begin VB.Menu mnuMoviePlay 
            Caption         =   "&play"
         End
         Begin VB.Menu mnuBreak5 
            Caption         =   "-"
         End
         Begin VB.Menu mnuMovieSlotNumber 
            Caption         =   "&slot number"
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&0"
               Index           =   0
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&1"
               Index           =   1
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&2"
               Index           =   2
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&3"
               Index           =   3
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&4"
               Index           =   4
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&5"
               Index           =   5
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&6"
               Index           =   6
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&7"
               Index           =   7
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&8"
               Index           =   8
            End
            Begin VB.Menu mnuMovieSlot 
               Caption         =   "&9"
               Index           =   9
            End
         End
      End
      Begin VB.Menu mnuBreak74754 
         Caption         =   "-"
      End
      Begin VB.Menu mnuAVIRecord 
         Caption         =   "&record avi movie..."
      End
      Begin VB.Menu mnuBreak4 
         Caption         =   "-"
      End
      Begin VB.Menu mnuQuit 
         Caption         =   "&quit"
      End
   End
   Begin VB.Menu mnuMainMenus 
      Caption         =   "&vm"
      Index           =   1
      Begin VB.Menu mnuRegion 
         Caption         =   "&region"
         Begin VB.Menu mnuEuropeanUS 
            Caption         =   "&export [master system]"
         End
         Begin VB.Menu mnuJapanese 
            Caption         =   "&japan [mark iii]"
         End
      End
      Begin VB.Menu mnuBreak1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuReset 
         Caption         =   "&reset"
      End
      Begin VB.Menu mnuPause 
         Caption         =   "&pause"
      End
      Begin VB.Menu mnuBreak6345 
         Caption         =   "-"
      End
      Begin VB.Menu mnuVideo 
         Caption         =   "&video"
         Begin VB.Menu mnuDisplaySize 
            Caption         =   "&display size"
            Begin VB.Menu mnuZoom 
               Caption         =   "&1x"
               Index           =   1
            End
            Begin VB.Menu mnuZoom 
               Caption         =   "&2x"
               Index           =   2
            End
            Begin VB.Menu mnuZoom 
               Caption         =   "&3x"
               Index           =   3
            End
            Begin VB.Menu mnuZoom 
               Caption         =   "&4x"
               Index           =   4
            End
         End
         Begin VB.Menu mnuFullScreen 
            Caption         =   "&full screen"
            Begin VB.Menu mnuFullScreenToggle 
               Caption         =   "&toggle"
            End
            Begin VB.Menu mnuBreak77 
               Caption         =   "-"
            End
            Begin VB.Menu mnuFullScreenConfigure 
               Caption         =   "&configure..."
            End
         End
         Begin VB.Menu mnuBorderLayers 
            Caption         =   "&border/layers"
            Begin VB.Menu mnuGameGearBorderToggle 
               Caption         =   "&show border [game gear]"
            End
            Begin VB.Menu mnuBreak9 
               Caption         =   "-"
            End
            Begin VB.Menu mnuLayerBG 
               Caption         =   "&show background"
            End
            Begin VB.Menu mnuLayerSprites 
               Caption         =   "&show sprites"
            End
            Begin VB.Menu mnuBreak8 
               Caption         =   "-"
            End
            Begin VB.Menu mnuBackgroundColor 
               Caption         =   "&background color"
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&black"
                  Index           =   0
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&blue"
                  Index           =   1
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&green"
                  Index           =   2
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&cyan"
                  Index           =   3
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&red"
                  Index           =   4
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&magenta"
                  Index           =   5
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&yellow"
                  Index           =   6
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&white"
                  Index           =   7
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&gray"
                  Index           =   8
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&light blue"
                  Index           =   9
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&light green"
                  Index           =   10
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&light cyan"
                  Index           =   11
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&light red"
                  Index           =   12
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&light magenta"
                  Index           =   13
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&light yellow"
                  Index           =   14
               End
               Begin VB.Menu mnuBackgroundColorN 
                  Caption         =   "&bright white"
                  Index           =   15
               End
            End
            Begin VB.Menu mnuBreak745 
               Caption         =   "-"
            End
            Begin VB.Menu mnuLimitSprites 
               Caption         =   "&disable sprite limit"
            End
         End
         Begin VB.Menu mnuBreak68565 
            Caption         =   "-"
         End
         Begin VB.Menu mnuAdvanceFrame 
            Caption         =   "&advance frame"
         End
         Begin VB.Menu mnuFastForward 
            Caption         =   "&fast forward"
         End
         Begin VB.Menu mnuBreak74574 
            Caption         =   "-"
         End
         Begin VB.Menu mnu3DOutput 
            Caption         =   "3d glasses output"
            Begin VB.Menu mnuDisable3DOutput 
               Caption         =   "&disabled"
            End
            Begin VB.Menu mnuBreak674 
               Caption         =   "-"
            End
            Begin VB.Menu mnuShowOnlyLeftSide 
               Caption         =   "&show only left side"
            End
            Begin VB.Menu mnuShowOnlyRightSide 
               Caption         =   "&show only right side"
            End
         End
         Begin VB.Menu mnuBreak5747 
            Caption         =   "-"
         End
         Begin VB.Menu mnuSaveScreenshot 
            Caption         =   "&save screenshot"
         End
      End
      Begin VB.Menu mnuAudio 
         Caption         =   "&audio"
         Begin VB.Menu mnuSampleRate 
            Caption         =   "&sample rate"
            Begin VB.Menu mnuSampleRates 
               Caption         =   "&11025"
               Index           =   0
            End
            Begin VB.Menu mnuSampleRates 
               Caption         =   "&22050"
               Index           =   1
            End
            Begin VB.Menu mnuSampleRates 
               Caption         =   "&44100"
               Index           =   2
            End
         End
         Begin VB.Menu mnuBreak63 
            Caption         =   "-"
         End
         Begin VB.Menu mnuMute 
            Caption         =   "&mute"
         End
      End
      Begin VB.Menu mnuInput 
         Caption         =   "&input"
         Begin VB.Menu mnuInputConfigure 
            Caption         =   "&configure..."
         End
         Begin VB.Menu mnuBreak7474 
            Caption         =   "-"
         End
         Begin VB.Menu mnuRapidFireUnit 
            Caption         =   "&rapid fire unit"
            Begin VB.Menu mnuControl1 
               Caption         =   "&control 1"
               Begin VB.Menu mnuButton1 
                  Caption         =   "&button 1"
               End
               Begin VB.Menu mnuButton2 
                  Caption         =   "&button 2"
               End
            End
            Begin VB.Menu mnuControl2 
               Caption         =   "&control 2"
               Begin VB.Menu mnuButton12 
                  Caption         =   "&button 1"
               End
               Begin VB.Menu mnuButton22 
                  Caption         =   "&button 2"
               End
            End
         End
      End
      Begin VB.Menu mnuBreak10 
         Caption         =   "-"
      End
      Begin VB.Menu mnuProActionReplay 
         Caption         =   "&pro action replay..."
      End
      Begin VB.Menu mnuBreak7468 
         Caption         =   "-"
      End
      Begin VB.Menu mnuMemoryEditor 
         Caption         =   "&memory editor..."
      End
   End
   Begin VB.Menu mnuMainMenus 
      Caption         =   "&other"
      Index           =   2
      Begin VB.Menu mnuAboutvbsms 
         Caption         =   "&about vbsms+..."
      End
   End
   Begin VB.Menu mnuBookmarks 
      Caption         =   "bookmarks"
      Begin VB.Menu mnuAddBookmark 
         Caption         =   "add bookmark..."
      End
      Begin VB.Menu mnuEditBookmark 
         Caption         =   "edit bookmark..."
      End
      Begin VB.Menu mnuRemoveBookmark 
         Caption         =   "remove bookmark"
      End
      Begin VB.Menu mnuBreak12 
         Caption         =   "-"
      End
      Begin VB.Menu mnuUseBookmarkForMemoryEditing 
         Caption         =   "use bookmark for memory editing"
      End
      Begin VB.Menu mnuBreak11 
         Caption         =   "-"
      End
      Begin VB.Menu mnuClearAllBookmarks 
         Caption         =   "clear all bookmarks"
      End
   End
   Begin VB.Menu mnuResults 
      Caption         =   "results"
      Begin VB.Menu mnuUseAddressForMemoryEditing 
         Caption         =   "use address for memory editing"
      End
   End
   Begin VB.Menu mnuPAR 
      Caption         =   "par"
      Begin VB.Menu mnuEnableAllCodes 
         Caption         =   "enable all codes"
      End
      Begin VB.Menu mnuDisableAllCodes 
         Caption         =   "disable all codes"
      End
      Begin VB.Menu mnuBreak4574 
         Caption         =   "-"
      End
      Begin VB.Menu mnuEnableCode 
         Caption         =   "enable code"
      End
      Begin VB.Menu mnuDisableCode 
         Caption         =   "disable code"
      End
      Begin VB.Menu mnuBreak45747 
         Caption         =   "-"
      End
      Begin VB.Menu mnuRemoveCode 
         Caption         =   "remove code"
      End
   End
End
Attribute VB_Name = "frmSMS"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Form_Resize()
  picScreen.left = 0
  picScreen.top = 0
  picScreen.Height = Me.ScaleHeight
  picScreen.Width = Me.ScaleWidth
End Sub

Private Sub Form_Unload(Cancel As Integer)

  If AVIRecording = True Then Call mnuAVIRecord_Click

  Call waveOutClose(glphWaveOut)
  Call settingssave

  End

End Sub

Private Sub mnuAboutvbsms_Click()

  Dim a As String

  a$ = "vbsms+ v3.1 (c) 2006-2008, kevin ""olaf"" miller" & vbCrLf & vbCrLf
  
  a$ = a$ & "emulates the sega mark iii, master system, and game gear." & vbCrLf & vbCrLf

  a$ = a$ & "vbsms+ is an enhanced continuation of the vbsms project by john ""brom"" casey. the majority of source code in vbsms+ was not written by me, therefore, i take no credit for the appropriate portions. however, all additions/alterations to the source code of vbsms are entirely by me [unless stated otherwise]." & vbCrLf & vbCrLf

  a$ = a$ & "a special thanks to the following people for their projects, contributions, or documentation: john ""brom"" casey, chris cowley, vbt, parasyte, maxim, asynchronous, marat fayzullin, charles macdonald, and omar ""bock"" cornut." & vbCrLf & vbCrLf

  a$ = a$ & "contains security software by david ireland of di management services pty ltd <www.di-mgt.com.au>." & vbCrLf & vbCrLf

  a$ = a$ & "please visit the official vbsms+ homepage: http://olaf.arc-nova.org/"

  Call MsgBox(a$, vbInformation, "about vbsms+")

End Sub
Private Sub mnuAddBookmark_Click()
  Call BookmarkAdd
End Sub

Private Sub mnuAdvanceFrame_Click()
  steppy = True
End Sub

Private Sub mnuAVIRecord_Click()

  Call AVIMovieRecord

End Sub
Private Sub mnuBackgroundColorN_Click(Index As Integer)

  BG_Color = Index% 'sets background color - QBColor integer

End Sub

Private Sub mnuButton1_Click()
  RFU1 = Not RFU1
End Sub

Private Sub mnuButton12_Click()
  RFU12 = Not RFU12
End Sub

Private Sub mnuButton2_Click()
  RFU2 = Not RFU2
End Sub


Private Sub mnuButton22_Click()
  RFU22 = Not RFU22
End Sub

Private Sub mnuClearAllCodes_Click()
  Call PARClear
End Sub

Private Sub mnuCloseROM_Click()

  On Error Resume Next

  Call mnuReset_Click

  Executing = False
  Pausing = False

  Call Kill(App.Path & "\folders\temporary\*.*") 'clears out the zips

  ROM_Name$ = ""

  Call BookmarksClear
  Call PARClear
  Call PARReset
  
  PAROpen = False
  
  Me.Caption = "vbsms+"

End Sub

Private Sub mnuDisable3DOutput_Click()
  Disable3D = Not Disable3D
End Sub

Private Sub mnuDisableAllCodes_Click()

  Dim a As Long

  If frmPAR.List1.ListCount = 0 Then
    Exit Sub
  End If

  For a = 0 To UBound(PARAddress)
    PARAddress(a) = 0
    PARValue(a) = 0
  Next a
  
  PAREnabled = False
  
End Sub

Private Sub mnuDisableCode_Click()

  Dim a As Long, b As String

  For a = LBound(PARAddress) To UBound(PARAddress)
    b$ = frmPAR.List1.Text
    b$ = Replace(b$, " ", "")
    If PARAddress(a) = CLng("&H" & left$(Mid$(b, 3), 4)) - 49152 And PARValue(a) = CLng("&H" & right$(b, 2)) Then
      PARAddress(a) = 0
      PARValue(a) = 0
      GoTo 1
    End If
  Next a
1:
  For a = LBound(PARAddress) To UBound(PARAddress)
    If PARAddress(a) <> 0 And PARValue(a) <> 0 Then
      PAREnabled = True
      Exit Sub
    End If
  Next a
  
  PAREnabled = False

End Sub

Private Sub mnuEditBookmark_Click()

  Call BookmarkEdit

End Sub

Private Sub mnuEnableAllCodes_Click()

  Dim a As Long

  If frmPAR.List1.ListCount = 0 Then
    Exit Sub
  End If

  For a = 0 To UBound(PARAddress)
    PARAddress(a) = 0
    PARValue(a) = 0
  Next a
  
  For a = 0 To frmPAR.List1.ListCount - 1
    b$ = frmPAR.List1.List(a)
    b$ = Replace(b$, " ", "")
    PARAddress(a) = CLng("&H" & left$(Mid$(b, 3), 4)) - 49152
    PARValue(a) = CLng("&H" & right$(b, 2))
  Next a
  
  PAREnabled = True

End Sub

Public Sub mnuEnableCode_Click()

  Dim a As Long

  For a = LBound(PARAddress) To UBound(PARAddress)
    If PARAddress(a) = 0 And PARValue(a) = 0 Then
      b$ = frmPAR.List1.Text
      b$ = Replace(b$, " ", "")
      PARAddress(a) = CLng("&H" & left$(Mid$(b, 3), 4)) - 49152
      PARValue(a) = CLng("&H" & right$(b, 2))
      PAREnabled = True
      Exit Sub
    End If
  Next a
  
End Sub

Private Sub mnuEuropeanUS_Click()
  usa = True
End Sub

Private Sub mnuFastForward_Click()
  fastforward = Not fastforward
End Sub

Private Sub mnuFullScreenConfigure_Click()
  Call frmConfigureFullScreen.Show
End Sub

Public Sub mnuFullScreenToggle_Click()

  If IsFullScreen Then
    Call Unload(frmFullScreen)
    If ScreenResolutionChange Then
      Call ChangeResolution(OriginalScreenWidth, OriginalScreenHeight)
    End If
    Call ShowCursor(True)
    Call Me.Show
  Else
    Call Me.Hide
    If ScreenResolutionChange Then
      Call ChangeResolution(FullScreenWidth, FullScreenHeight)
    End If
    Call ShowCursor(False)
    Call frmFullScreen.Show
  End If

End Sub
Private Sub mnuGameGearBorderToggle_Click()
  DoGameGearBorder = Not DoGameGearBorder 'toggle it!
End Sub

Private Sub mnuInputConfigure_Click()

  Call frmConfigureInput.Show

End Sub

Private Sub mnuJapanese_Click()
  usa = False
End Sub

Private Sub mnuLayerBG_Click()
  Layerdrawbg = Not Layerdrawbg
End Sub

Private Sub mnuLayerSprites_Click()
  LayerDrawSprites = Not LayerDrawSprites
End Sub


Private Sub mnuLimitSprites_Click()
  LimitSprites = Not LimitSprites 'switch sprite limiting
End Sub

Private Sub mnuLoadROM_Click()

  CommonDialog1.filename = ""
  CommonDialog1.DialogTitle = "load rom"
  CommonDialog1.Filter = "supported files (*.gg;*.sms;*.zip)|*.gg;*.sms;*.zip"
  Call CommonDialog1.ShowOpen

  Call loadrom(CommonDialog1.filename$)

End Sub

Private Sub mnuMainMenus_Click(Index As Integer)

  Dim a As Integer
    
  '//REGION RELATED
  If usa Then mnuEuropeanUS.Checked = True: mnuJapanese.Checked = False
  If Not usa Then mnuEuropeanUS.Checked = False: mnuJapanese.Checked = True

  If ShowOnlyleft = True Then mnuShowOnlyLeftSide.Checked = True: mnuShowOnlyRightSide.Checked = False
  If ShowOnlyleft = False Then mnuShowOnlyLeftSide.Checked = False: mnuShowOnlyRightSide.Checked = True
  

  '//RAPID FIRE UNIT RELATED
  mnuButton1.Checked = RFU1
  mnuButton2.Checked = RFU2
  mnuButton12.Checked = RFU12
  mnuButton22.Checked = RFU22

  For a% = 0 To 2
    mnuSampleRates(a%).Checked = False
  Next a%
  mnuSampleRates(CurrentSampleRate).Checked = True

  For a% = 0 To 9
    mnuStateSlot(a%).Checked = False
    mnuMovieSlot(a%).Checked = False
  Next a%
  mnuStateSlot(StateSlot).Checked = True
  mnuMovieSlot(MovieSlot).Checked = True
  mnuPause.Enabled = Executing
  mnuReset.Enabled = Executing
  mnuCloseROM.Enabled = Executing
  mnuStateSave.Enabled = Executing
  mnuFastForward.Checked = fastforward
  mnuFastForward.Enabled = Executing
  mnuStateLoad.Enabled = Executing
  mnuMoviePlay.Enabled = Executing
  mnuMovieRecord.Enabled = Executing
  mnuSaveScreenshot.Enabled = Executing
  mnuLoadROM.Enabled = Not Executing
  mnuAVIRecord.Enabled = Executing
  mnuProActionReplay.Enabled = Executing
  mnuMemoryEditor.Enabled = Executing
  
  If Executing = True Then
    If MoviePlaying = False Then
      mnuMovieRecord.Enabled = True
    Else
      mnuMovieRecord.Enabled = False
    End If
    If MovieRecording = False Then
      mnuMoviePlay.Enabled = True
    Else
      mnuMoviePlay.Enabled = False
    End If
  Else
    mnuMovieRecord.Enabled = False
    mnuMoviePlay.Enabled = False
  End If

  mnuPause.Checked = Pausing
  mnuAdvanceFrame.Enabled = Pausing
  mnuMute.Checked = Mutey

  mnuZoom(1).Checked = False
  mnuZoom(2).Checked = False
  mnuZoom(3).Checked = False
  mnuZoom(4).Checked = False
  mnuZoom(Zoom_Size).Checked = True

  mnuLayerSprites.Checked = LayerDrawSprites
  mnuLayerBG.Checked = Layerdrawbg

  For a% = 0 To 15
    mnuBackgroundColorN(a%).Checked = False
  Next a%
  mnuBackgroundColorN(BG_Color%).Checked = True

  mnuGameGearBorderToggle.Checked = DoGameGearBorder
  mnuLimitSprites.Checked = Not LimitSprites
  mnuDisable3DOutput.Checked = Disable3D

End Sub
Private Sub mnuMemoryEditor_Click()
  Call frmMemoryEditor.Show 'show memory editor
End Sub

Private Sub mnuMoviePlay_Click()
  If Not MoviePlaying Then
    Call MoviePlay
  Else
    Call MoviePlayStop
  End If
End Sub

Private Sub mnuMovieRecord_Click()
  If Not MovieRecording Then
    Call MovieRecord
  Else
    Call MovieRecordStop
  End If
End Sub

Private Sub mnuMovieSlot_Click(Index As Integer)
  MovieSlot = Index 'change movie slot
End Sub

Private Sub mnuMute_Click()

  Mutey = Not Mutey
  
  If Mutey = True Then
    waveOutClose glphWaveOut
  Else
    initializewaveout
  End If
  
End Sub

Private Sub mnuPause_Click()
  Pausing = Not Pausing
End Sub

Private Sub mnuProActionReplay_Click()

  Call frmPAR.Show

End Sub

Private Sub mnuQuit_Click()
  Call Unload(Me)
End Sub

Private Sub mnuRemoveBookmark_Click()
  Call BookmarkRemove
End Sub

Private Sub mnuRemoveCode_Click()

  Call PARRemove

End Sub

Public Sub mnuReset_Click()

  Call MoviePlayStop
  Call MovieRecordStop
  
  If AVIRecording = True Then Call mnuAVIRecord_Click

  Call vdp.reset
  Call z80.Z80Reset
  Call initializewaveout
  Call PSG.psg_init(MASTER_CLOCK, WAVE_FREQUENCY) ' 7680)

End Sub

Private Sub mnuSampleRates_Click(Index As Integer)
  
  Call waveOutClose(glphWaveOut)
  
  Call psg_reset
  
  Call samplerate(Index)
  
  Call initializewaveout

End Sub

Private Sub mnuSaveScreenshot_Click()

  Dim f As Integer

  f = 0

  If fileexists(App.Path & "\folders\screenshots\" & ROM_Name$ & " (" & f & ").bmp") = True Then
    Do
      f = f + 1
      DoEvents
    Loop Until fileexists(App.Path & "\folders\screenshots\" & ROM_Name$ & " (" & f & ").bmp") = False
  End If

  If IsFullScreen = True Then
    Call SavePicture(exportbmp(frmFullScreen.picScreen), App.Path & "\folders\screenshots\" & ROM_Name$ & " (" & f & ").bmp")
  Else
    Call SavePicture(exportbmp(picScreen), App.Path & "\folders\screenshots\" & ROM_Name$ & " (" & f & ").bmp")
  End If

End Sub

Private Sub mnuShowOnlyLeftSide_Click()
  ShowOnlyleft = Not ShowOnlyleft
End Sub

Private Sub mnuShowOnlyRightSide_Click()
  ShowOnlyleft = Not ShowOnlyleft
End Sub
Private Sub mnuStateLoad_Click()
  Call StateLoad
End Sub
Private Sub mnuStateSave_Click()
  Call StateSave
End Sub

Private Sub mnuStateSlot_Click(Index As Integer)
  StateSlot = Index 'changes slot
End Sub

Private Sub mnuUseAddressForMemoryEditing_Click()
  frmMemoryEditor.Text1.Text = frmValueSearch.List1.Text 'use for memory editing
End Sub

Private Sub mnuUseBookmarkForMemoryEditing_Click()
  frmMemoryEditor.Text1.Text = left$(frmMemoryEditor.lstBookmarks.Text, 5) 'use address for memory editing
End Sub

Private Sub mnuZoom_Click(Index As Integer)
  Me.Visible = False
  Zoom_Size = Index
  Call windowscale(Zoom_Size)
  Me.Visible = True
End Sub

Public Sub picScreen_KeyDown(KeyCode As Integer, Shift As Integer)

  Select Case KeyCode
    Case Input1_Up
      controller1 = controller1 And Not 1&
    Case Input1_Down
      controller1 = controller1 And Not 2&
    Case Input1_Left
      controller1 = controller1 And Not 4&
    Case Input1_Right
      controller1 = controller1 And Not 8&
    Case Input1_1
      If RFU1 = False Then
        controller1 = controller1 And Not 16&
      Else
        If Not IsGameGear Then
          If RFU1Bool = False Then
            controller1 = controller1 And Not 16&
          Else
            controller1 = controller1 Or 16&
          End If
          RFU1Bool = Not RFU1Bool
        End If
      End If
    Case Input1_2
      If RFU2 = False Then
        controller1 = controller1 And Not 32&
      Else
        If Not IsGameGear Then
          If RFU2Bool = False Then
            controller1 = controller1 And Not 32&
          Else
            controller1 = controller1 Or 32&
          End If
          RFU2Bool = Not RFU2Bool
        End If
      End If
    Case Input1_GGStart: ggcontroller = ggcontroller And Not 128&
    Case Input1_Pause: Call z80.pushw(&H66)
    Case Input2_Up
      controller1 = controller1 And Not 64&
    Case Input2_Down
      controller1 = controller1 And Not 128&
    Case Input2_Left
      controller2 = controller2 And Not 1&
    Case Input2_Right
      controller2 = controller2 And Not 2&
    Case Input2_1
      If RFU12 = False Then
        controller2 = controller2 And Not 4&
      Else
        If RFU1Bool2 = False Then
          controller2 = controller2 And Not 4&
        Else
          controller2 = controller2 Or 4&
        End If
        RFU1Bool2 = Not RFU1Bool2
      End If
    Case Input2_2
      If RFU22 = False Then
        controller2 = controller2 And Not 8&
      Else
        If RFU2Bool2 = False Then
          controller2 = controller2 And Not 8&
        Else
          controller2 = controller2 Or 8&
        End If
        RFU2Bool2 = Not RFU2Bool2
      End If
  End Select

End Sub
Public Sub picScreen_KeyUp(KeyCode As Integer, Shift As Integer)

  Select Case KeyCode
    Case 8 'backspace
      If Shift = 0 Then 'if not shift
        If Executing = True Then Call mnuReset_Click: Exit Sub
      Else 'if shift
        If Executing = True Then Call mnuCloseROM_Click: Exit Sub
      End If
    Case 19 'pause/break
      If Executing = True Then Call mnuPause_Click: Exit Sub
    Case vbKeyEscape 'esc
      If mnuFullScreenToggle = True Then Call mnuFullScreenToggle_Click: Exit Sub
    Case vbKeyF1 'f1
      If Not IsFullScreen And Executing = False Then Call mnuLoadROM_Click: Exit Sub
    Case vbKeyF5 'f5
      If Executing = True Then Call mnuStateSave_Click
    Case vbKeyF6 'f6
      If Executing = True Then Call mnuStateLoad_Click
    Case vbKeyF7 'f7
      If Shift = 0 Then
        If Executing = True Then Call mnuMovieRecord_Click
      Else
        If Executing = True Then Call mnuAVIRecord_Click
      End If
    Case vbKeyF8 'f8
      If Executing = True Then Call mnuMoviePlay_Click
    Case vbKeyF9 'f9
      Call mnuLayerBG_Click
    Case vbKeyF10 'f10
      Call mnuLayerSprites_Click
    Case vbKeyF11 'f11
      If Shift = 0 Then
        If Executing = True Then Call mnuAdvanceFrame_Click
      Else
        If Executing = True Then Call mnuFastForward_Click
      End If
    Case vbKeyF12 'f12
      If Executing = True Then Call mnuSaveScreenshot_Click
  End Select

  Select Case KeyCode
    Case Input1_Up: controller1 = controller1 Or 1&
    Case Input1_Down: controller1 = controller1 Or 2&
    Case Input1_Left: controller1 = controller1 Or 4&
    Case Input1_Right: controller1 = controller1 Or 8&
    Case Input1_1: controller1 = controller1 Or 16&
    Case Input1_2: controller1 = controller1 Or 32&
    Case Input1_GGStart: ggcontroller = ggcontroller Or 128&
    Case Input2_Up: controller1 = controller1 Or 64&
    Case Input2_Down: controller1 = controller1 Or 128&
    Case Input2_Left: controller2 = controller2 Or 1&
    Case Input2_Right: controller2 = controller2 Or 2&
    Case Input2_1: controller2 = controller2 Or 4&
    Case Input2_2: controller2 = controller2 Or 8&
  End Select

End Sub
Private Sub picScreen_Paint()

  If Pausing = True Then 'checks if pausing
    Call blitscreen 'redraw screen
    DoEvents 'cpu shit
  End If

End Sub

Private Sub Timer1_Timer()

  If Not MoviePlaying And Not MovieRecording And Executing Then
    Call JoystickInput 'get joystick input
  End If

End Sub
